# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=gsm
pkgver=1.0.19
pkgrel=1
_soname=1.0.12
pkgdesc="Shared libraries for GSM speech compressor"
url="http://www.quut.com/gsm/"
arch="all"
license="custom:TU-Berlin-2.0"
makedepends="$depends_dev"
subpackages="$pkgname-dev $pkgname-doc $pkgname-tools"
source="http://www.quut.com/gsm/gsm-$pkgver.tar.gz
	gsm-64bit.patch
	gsm-makefile.patch
	"

builddir="$srcdir"/gsm-${pkgver%.*}-pl${pkgver##*.}

build() {
	export RPM_OPT_FLAGS="$CFLAGS -fPIC"
	make all
}

check() {
	make addtst
}

package() {
	mkdir -p "$pkgdir"/usr/bin \
		"$pkgdir"/usr/include/gsm \
		"$pkgdir"/usr/lib \
		"$pkgdir"/usr/share/man/man1 \
		"$pkgdir"/usr/share/man/man3

	make -j1 install \
		INSTALL_ROOT="$pkgdir"/usr \
		GSM_INSTALL_INC="$pkgdir"/usr/include/gsm \
		GSM_INSTALL_LIB="$pkgdir"/usr/lib
	cp -p lib/libgsm.so.$_soname "$pkgdir"/usr/lib/
	ln -s libgsm.so.$_soname "$pkgdir"/usr/lib/libgsm.so.1
	ln -s libgsm.so.$_soname "$pkgdir"/usr/lib/libgsm.so

	ln -s gsm/gsm.h "$pkgdir"/usr/include/
	rm -f "$pkgdir"/usr/lib/lib*.a
}

tools() {
	pkgdesc="GSM speech compressor tools"
	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr
}

sha512sums="f69b4bf2d918b118b5de90b8ab88fd026008ac7432f07b872b81fe52cdc781f605dca8eedcdaebc8beb974cef388496c618f92a41961c62057009964159f8392  gsm-1.0.19.tar.gz
5b01f6d2fd3ee7cd859da70870463e2ccc6614c5fb1bd5efc88a223a0c5477271221557fef13ba46697e70cc5820c13efff738413f8990d5884b95cc89c30152  gsm-64bit.patch
1d92b7eacf52e5281c9f1a0f08313d10f15c35d22fb2292e5a885ceb3cb766557a5e3a08954db75fb13db59345ef9f6b08939881ba38c9d384e09a1c96b47bc5  gsm-makefile.patch"
